using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Runtime.Serialization;



namespace ShrapnelTest
{

	[DataContract()]
	class TestNode : Shrapnel.Node
	{
		[DataMember(Name="BoxArea")]
		private Shrapnel.Areas.Box boxArea;


		public TestNode(PointF position)
		{
			boxArea = new Shrapnel.Areas.Box();
			boxArea.BoxArea = new RectangleF(position.X, position.Y, 100, 100);
			
			OccupiedArea.Add(boxArea);

			// Create a few connectors
			for (int y=8; y<100; y+=20)
			{
				TestConnector connector;
				
				connector = new TestConnector(new PointF(position.X + 104, position.Y + y));
				Connectors.Add(connector);

				connector = new TestConnector(new PointF(position.X - 4, position.Y + y));
				Connectors.Add(connector);
			}
		}


		public override void Draw(Graphics graphics, Shrapnel.ViewState viewState)
		{
			RectangleF areaOnScreen = viewState.WorldToScreen(boxArea.BoxArea);
			
			using (Brush brush = new SolidBrush(IsSelected ? Color.Yellow : Color.White))
			{
				using (Pen pen = new Pen(Color.Black))
				{
					graphics.FillRectangle(brush, areaOnScreen);

					graphics.DrawRectangle(pen,
						areaOnScreen.X,
						areaOnScreen.Y,
						areaOnScreen.Width,
						areaOnScreen.Height);
				}
			}


			base.Draw(graphics, viewState);
		}
	}
}
